/**************************************************
* 创建作者：	咕咕咕
* 创建时间：	2020-12-14
* 作用描述：	#数字的缓冲
***************************************************/

using System.Text;

namespace Utils.Calc
{
	internal class OperandBuffer
	{
		#region ----字段----
		private const string include = "0123456789.";
		private StringBuilder buffer;
		#endregion

		#region ----属性----
		public double Number => double.Parse(buffer.ToString());

		public int Length => buffer.Length;
		#endregion

		#region ----构造方法----
		public OperandBuffer()
        {
			buffer = new StringBuilder();
        }

		public OperandBuffer(char c)
		{
			buffer = new StringBuilder(c);
		}

		public OperandBuffer(string s)
		{
			buffer = new StringBuilder(s);
		}
		#endregion

		#region ----静态方法----
		public static bool IsNumber(char c)
		{
			return include.IndexOf(c) != -1;
		}
		#endregion

		#region ----公有方法----
		public void Append(char c)
        {
			buffer.Append(c);
		}

		public void Clear()
        {
			buffer.Clear();
        }

        public override string ToString()
        {
            return buffer.ToString();
        }
        #endregion
    }
}